package com.draemoncode.event;

import java.util.HashMap;
import java.util.Map;

import javax.swing.JFrame;

import org.apache.mina.core.session.IoSession;

import com.draemoncode.constant.MessageFieldConstant;
import com.draemoncode.constant.QiangZhuangFieldConstant;
import com.draemoncode.util.JSONUtil;
import com.draemoncode.vo.Message;

public class QiangzhuangEvent implements IEvent{
	
	public final static Integer rqutype = 1;
	public final static Integer restype = 163;

	@Override
	public void busiAction(IoSession session, JFrame view, Map<String, Object> args) {
		String money = String.valueOf(args.get(QiangZhuangFieldConstant.MONEY));
		String syncid = String.valueOf(args.get(QiangZhuangFieldConstant.SYNCID));
		String name = String.valueOf(args.get(QiangZhuangFieldConstant.NAME));
		String response = JSONUtil.toJson(new Message(restype, Integer.valueOf(syncid), "当前庄家：" + name));
		session.write(response);
	}

	@Override
	public void viewAction(IoSession session, JFrame view, Map<String, Object> args) {
		
	}

	@Override
	public boolean shoudProcess(Map<String, Object> args) {
		Integer typeArgs = Integer.valueOf(String.valueOf(args.get(MessageFieldConstant.TYPE)));
		if(rqutype.equals(typeArgs)){
			return true;
		}
		return false;
	}

}
